package com.liujit.web.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.liujit.common.utils.JacksonUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

/**
 * @author Chen Long
 * @version 1.0
 * @className JacksonConfig
 * @description Jackson 配置
 * @date 2020/9/12
 */
@Configuration
@ConditionalOnClass(ObjectMapper.class)
public class JacksonConfig {

    @Bean
    public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
        ObjectMapper objectMapper = builder.createXmlMapper(false).build();
        JacksonUtil.initObjectMapper(objectMapper);
        return objectMapper;
    }

}
